package com.losl.framework.controller;

import com.losl.common.core.domain.Result;
import com.losl.common.core.domain.model.LoginBody;
import com.losl.framework.web.service.SysUserLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * 用户登陆验证
 * @author Maxwell
 * @date 2021-5-13
 */
@RestController
@Api(value = "登陆-API",tags = "登陆相关接口")
public class UserLoginController {
    @Autowired
    private SysUserLoginService loginService;
    @Autowired
    private AuthenticationManager manager;

    @ApiOperation("登陆，需要验证码获取的uuid和验证码")
    @PostMapping("/login")
    public Result login(@RequestBody LoginBody loginBody){
        Result result = Result.success();
        HashMap<String, Object> loginData = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), loginBody.getUuid());
        result.putAll(loginData);
        return result;
    }
}
